﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq;
using System.Text;
using WMSADBUtility;

namespace ElectronicWMSA.List.Second
{
    public class ExcelLog_BLL
    {

        public int Add(ExcelLog_Entity model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("INSERT INTO T_Excel_Log (");
            strSql.Append("ExcelName,ExcelFile,CreateTime)");
            strSql.Append("values (");
            strSql.Append("@ExcelName,@ExcelFile,@CreateTime)");
            strSql.Append(";select @@IDENTITY");

            Database db = DatabaseFactory.CreateDatabase();
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
            db.AddInParameter(dbCommand, "ExcelName", DbType.AnsiString, model.ExcelName);
            db.AddInParameter(dbCommand, "ExcelFile", DbType.Binary, model.ExcelFile);
            db.AddInParameter(dbCommand, "CreateTime", DbType.DateTime, model.CreatTime);
            int result;
            object obj = db.ExecuteScalar(dbCommand);
            if(!int.TryParse(obj.ToString(),out result))
            {
                return 0;
            }
            return result;
        }


    }
}
